// pages/mch/order/index.js
const App = getApp()

Page({
  data: {
    init: false,
    tab: '0',
    tabIndex: 0,

    CustomBar: App.Global.CustomBar,
    cid: '',
    mid: '',

    all: 0,
    rund: 0,
    nos: 0,
    end: 0,
  },
  onLoad(options) {
    this.setData({
      init: true,
      cid: options.cid || '',
      mid: options.mid || '',
    })
  },
  // 滑动切换
  doSwiperChange(e) {
    let target = e.detail.currentItemId
    if (this.data.tab === target) {
      return
    }
    this.setData({
      tab: target
    })
  },
  // 跳转页面
  toPage(e) {
    wx.navigateTo({
      url: e.currentTarget.dataset.uri
    })
  },
  onTotalSet(e) {
    if (e.detail.type == 'all') {
      this.setData({
        all: e.detail.value
      })
    } else if (e.detail.type == 'rund') {
      this.setData({
        rund: e.detail.value
      })
    } else if (e.detail.type == 'nos') {
      this.setData({
        nos: e.detail.value
      })
    } else if (e.detail.type == 'end') {
      this.setData({
        end: e.detail.value
      })
    }
  },
  toSwiper(e) {
    this.setData({
      tabIndex: parseInt(e.currentTarget.dataset.idx)
    })
  }
})